package com.example.api.user;

import com.example.springcloud.common.ResponseEntity;
import com.example.springcloud.common.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 莫磊
 * @date 2025/8/21
 * @description
 */
// 指定注册中心的服务名（spring.application.name）,url公共前缀，fallback指定降级类
@FeignClient(name = "USER-SERVICE", path = "/user", fallback = UserApiFallback.class)
public interface UserApi {


    @GetMapping("/getById/{id}")
    ResponseEntity<User> getById(@PathVariable("id") Long id);

    @PostMapping("/addUser")
    ResponseEntity<User> addUser(User user);
;
    @GetMapping("/findByNameLike/{name}")
    ResponseEntity<List<User>> findByNameLike(@PathVariable("name") String name);

}
